<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of mmy_core_ApplicationRegistry
 *
 * @author Manu
 */
class mmy_core_ApplicationRegistry {
    private static $instance;
    private $freezeDir="data";
    private $values=array();
    private $mtimes=array();
    
    private function _construct() {}
    
    static function instance() {
        if (!isset(self::$instance)) { self::$instance = new self(); }
        return self::$instance;
    }
    
    protected function get($key){
        $path=$this->freezeDir.DIRECTORY_SEPARATOR.$key;
        if (file_exists($path)) {
            clearstatcache();
            $mtime=filemtime($path);
            
            if (!isset($this->mtimes[$key])) { $this->mtimes[$key]=0; }
            if ($mtime > $this->mtimes[$key]) {
                $data = file_get_contents($path);
                $this->mtimes[$key]=$mtime;
                return ($this->values[$key]=unserialize($data));
            }
        }
//        if (isset())
    }
}

?>
